<?php
namespace app\merchant\controller;

use app\common\controller\TestBase;
use app\common\model\Momerchant;
use think\Controller;
use think\Session;

class Seting extends TestBase
{
    public function index()
    {
        return $this->fetch();
    }

    public function momachinfo(){
        $Momerchant = new Momerchant();
        $map['id'] = Session::get('login_top_mid');
        $moinfo = $Momerchant->where($map)->find();
        if (Request()->isAjax()){
            $arr = request()->post();
//            return json($arr);
            $data['img_wx'] = $arr['img_abs'];
            $data['img'] = $arr['img'];
            $data['contacts'] = $arr['contacts'];
            $data['tel'] = $arr['tel'];
            $data['cust_call'] = $arr['cust_call'];
            $res = $Momerchant->save($data,$map);
            if ($res){
                $rest['code'] = 0;
                $rest['mesage'] = '设置成功';
            }else{
                $rest['code'] = 9001;
                $rest['mesage'] = '设置失败';
            }
            return json($rest);
        }else {
            $this->assign('moinfo', $moinfo);
            return $this->fetch();
        }
    }
}
